package com.xjscrm.console.web.seat;

import com.xjscrm.common.param.seat.SeatBuyParam;
import com.xjscrm.common.param.seat.SeatOptParam;
import com.xjscrm.common.param.seat.SeatSearchParam;
import com.xjscrm.common.vo.seat.SeatBuyVo;
import com.xjscrm.common.vo.seat.SeatPriceVO;
import com.xjscrm.common.vo.seat.SeatVo;
import com.xjscrm.console.common.util.LoginContext;
import com.xjscrm.console.param.BaseDto;
import com.xjscrm.console.service.common.seat.SeatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "席位管理", tags = "席位管理")
@RestController
@RequestMapping(value = "/seat")
public class SeatController {

    @Autowired
    private SeatService seatService;
    @ApiOperation(value = "查询席位数", notes = "查询席位数",response = Integer.class)
    @PostMapping(value ="/totalSeatNum")
    public Object totalSeatNum(@RequestBody BaseDto baseDto)throws Exception{
      return  seatService.totalSeatNum(baseDto);
    }

    @ApiOperation(value = "查询席位", notes = "查询席位", response = SeatVo.class)
    @PostMapping("/search")
    public Object getSeat(@RequestBody SeatSearchParam searchParam)throws Exception {
        return seatService.getSeat(searchParam);
    }

    @ApiOperation(value = "删除席位", notes = "删除席位", response = Boolean.class)
    @PostMapping("/delete")
    public Object deleteSeat(@RequestBody SeatOptParam opt) throws Exception{
        opt.setChildId(LoginContext.getLogin().getId());
        return seatService.delete(opt);

    }

    @ApiOperation(value = "续费席位", notes = "续费席位", response = SeatBuyVo.class)
    @PostMapping("/renewal")
    public Object renewalSeat(@RequestBody SeatBuyParam opt)throws Exception{
        opt.setChildId(LoginContext.getLogin().getId());
        return seatService.renewal(opt);
    }

    @ApiOperation(value = "购买席位", notes = "购买席位", response = SeatBuyVo.class)
    @PostMapping("/buy")
    public Object buySeat(@RequestBody SeatBuyParam opt) throws Exception{
        opt.setChildId(LoginContext.getLogin().getId());
        return seatService.buy(opt);
    }

    @ApiOperation(value = "购买席位确认", notes = "购买席位确认", response = Boolean.class)
    @PostMapping("/confirm")
    public Object buySeatConfirm(@RequestBody SeatOptParam opt) {
        opt.setChildId(LoginContext.getLogin().getId());
        return seatService.buySeatConfirm(opt);

    }


    @ApiOperation(value = "购买席位价格", notes = "购买席位价格", response = SeatPriceVO.class)
    @PostMapping("/price")
    public Object buySeatPrice() {
        return seatService.buySeatPrice();

    }
}
